package com.itheima.controller;

import com.itheima.config.ItcastConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Author Andy
 * @Description //TODO UserController
 * @Date 2022/3/5 8:44 上午
 * @Version 1.0
 **/
@RestController
@RequestMapping("/users")
public class UserController {

    @Value("${lesson}")
    private String lesson;


    @Value("${beijing.floor}")
    private String floor;

    @Value("${enterprise.name}")
    private String name;

//    age 写成字符串 如果需要解析成数字，还得单独处理
    @Value("${enterprise.age}")
    private String age;

    @Value("${enterprise.tel}")
    private String tel;

    @Value("${enterprise.subject[0]}")
    private String subject0;

    @Value("${enterprise.subject[1]}")
    private String subject1;

    @Value("${enterprise.subject[2]}")
    private String subject2;

    @Autowired
    private Environment environment;


    @Autowired
    private ItcastConfig itcastConfig;

//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @GetMapping("/{id}")
    public String getById(@PathVariable("id") Integer id){
        System.out.println("config parse lesson" + lesson);
        System.out.println("config parse name" + name);
        System.out.println("config parse age" + age);
        System.out.println("config parse tel" + tel);
        System.out.println("config parse subject0" + subject0);
        System.out.println("config parse subject1" + subject1);
        System.out.println("config parse subject2" + subject2);
        System.out.println("config parse environment " + environment);
        System.out.println("config parse environment lesson " + environment.getProperty("lesson"));
        System.out.println("config parse environment name " + environment.getProperty("enterprise.name"));
        System.out.println("config parse environment age " + environment.getProperty("enterprise.age"));
        System.out.println("config parse environment tel " + environment.getProperty("enterprise.tel"));
        System.out.println("config parse environment subject " + environment.getProperty("enterprise.subject[0]"));
        System.out.println("itcastConfig " + itcastConfig);
        return "user info";
    }
}
